<?php
/**
 * ShopEx licence
 *
 * @copyright  Copyright (c) 2005-2010 ShopEx Technologies Inc. (http://www.shopex.cn)
 * @license  http://ecos.shopex.cn/ ShopEx License
 */

class wxapi_ctl_admin_navigator extends desktop_controller
{
    public function apple()
    {
        $catMdl = app::get('b2c')->model('goods_cat');
        $catList = $catMdl->getList('cat_name,cat_id',array('disabled'=>'false'));
        $tagMdl = app::get('desktop')->model('tag');
        $tagList = $tagMdl->getList('tag_id,tag_name',array('tag_type'=>'goods','show_small_tag'=>1),0, -1, 'display_order desc');
        if($_POST) {
            $navigator = $_POST['wxapps'];
            $this->begin();
            app::get('wxapi')->setConf('wxapps.navigator',$navigator);
            $this->end(true,'保存成功');
        }
        $navigator = app::get('wxapi')->getConf('wxapps.navigator');
        foreach ($navigator as $k=>$v) {
            $navigator[$k]['thumLogo'] = base_storager::image_path($v['thumLogo']);
        }

        $this->pagedata['wxapps'] = $navigator;
        $this->pagedata['catList'] = $catList;
        $this->pagedata['tagList'] = $tagList;
        $this->page('admin/navigator.html');
    }

    private function __formatting()
    {
        $list = array(
            array(
                'code'      =>'2',
                'type'      =>'cat',
                'name'      =>'T恤',
                'thumLogo'  =>'https://cacheimage.ishopex.cn/public/images/72/bc/94/cdf0f83905cbf8a295372988776670b3254bbd8d.jpg?1528357957#h',
            ),
            array(
                'code'      =>'4',
                'type'      =>'cat',
                'name'      =>'连衣裙',
                'thumLogo'  => kernel::base_url(1).'/wxapp/images/home/dress_basic.jpg',
            ),
            array(
                'code'      =>'3',
                'type'      =>'cat',
                'name'      =>'衬衫',
                'thumLogo'  =>'https://cacheimage.ishopex.cn/public/images/aa/49/4d/60718c6bf367f48e248e46c743bfccac86f1cd8a.jpg?1528357974#h',
            ),
            array(
                'code'      =>'16',
                'type'      =>'tag',
                'name'      =>'时尚基本款',
                'thumLogo'  => kernel::base_url(1).'/wxapp/images/home/fashion_basic.jpg',
            ),
            array(
                'code'      =>'5',
                'type'      =>'cat',
                'name'      =>'半身裙',
                'thumLogo'  =>'https://cacheimage.ishopex.cn/public/images/3e/1d/15/c167bc23478965381fe37f63375bb132cb24da53.jpg?1528358094#h',
            ),
            array(
                'code'      =>'26,60',
                'type'      =>'cat',
                'name'      =>'短裤',
                'thumLogo'  =>'https://cacheimage.ishopex.cn/public/images/3c/da/1b/aaf2e63b05f41a90f31c1ffadce4c502cb8ed712.jpg?1528371136#h',
            ),
            array(
                'code'      =>'53,27',
                'type'      =>'cat',
                'name'      =>'休闲长裤',
                'thumLogo'  => kernel::base_url(1).'/wxapp/images/home/trousers_basic.jpg',
            ),
            array(
                'code'      =>'60,64',
                'type'      =>'cat',
                'name'      =>'牛仔裤',
                'thumLogo'  => kernel::base_url(1).'/wxapp/images/home/cowboy_basic.jpg',
            ),
        );
        return $list;
    }

    public function pullTarget()
    {
        $_type = $_GET['type'];
        echo "<option value=\"tag\"></option>";
    }
}